package grupb.upf.imageProcessing;


import java.awt.image.BufferedImage;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;
import javax.media.jai.PlanarImage;

public final class Brightness {

    public PlanarImage execute(PlanarImage image, int brightness) {

        BufferedImage aux;
        aux = image.getAsBufferedImage();
        BufferedImage buff = new BufferedImage(aux.getWidth(),
                aux.getHeight(), aux.getType());
        final Kernel kernel = new Kernel(1, 1, new float[] {brightness});
        ConvolveOp op = new ConvolveOp(kernel);
        op.filter(aux, buff);

        return PlanarImage.wrapRenderedImage(buff);
    }
}
